<?php
namespace app\controller;

use app\BaseController;
use app\service\LoginService;
use app\service\PermissionService;
use app\utils\CaptchaUtils;
use app\validate\LoginValidate;
use think\exception\ValidateException;
use think\facade\Db;
use \think\facade\Request;
use think\captcha\facade\Captcha;
use think\facade\Config;

class Menu extends BaseController
{
    //显示所拥有权限的菜单列表(侧边栏)

    public function havePermissionMenu(){
        $uid     = Request::param('uid/d', 0);
        $permissionData=PermissionService::getAllPermissionByUid($uid);

        $tree=[];

        foreach ($permissionData as $k=>$v){
            if ($v['pid']==0){
                $tree[$v['id']]=$v;
            }else{
                $tree[$v['pid']]['children'][]=$v;
            }
        }

        echo json_encode(array_values($tree));die();

    }




}
